<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<%@ page import="com.hzqy.commons.utils.SystemConfigUtils" %> 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>角色</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link href="../../static/css/uploadify.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css">

<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>
<script src="../../static/js/jquery.uploadify.js" type="text/javascript"></script>
<%
	String f_cc_id = request.getParameter("f_cc_id");
	if(f_cc_id == null){
		f_cc_id="0";
	}
	String public_net_url = SystemConfigUtils.getSysConfig("public_net_url");
%>
<script type="text/javascript">
		var queryParams;
		var cloudTwoPlaneUrl="<%=public_net_url%>";
		function EasyuiDatagrid() {
			$("#easyui-datagrid").datagrid({
				url: '../../content/selectOrgListByModelId.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams:getGueryParams(),
				columns: [[
					{field:'f_po_id',title:'模板ID',align:'center',width:50},
					{field:'f_po_name',title:'行业客户',align:'center',width:250},
					{field:'f_po_createAt',title:'添加时间',align:'center',width:150},
					{field:'f_po_model_name',title:'关联模板展示_<span style="color:red;">请使用机顶盒网络</span>',align:'center',width:300,
						formatter:function(value,row,index) {
							var str = "";//"模板";
							str+= '<a href="javascript:jumpModelTest('+row.f_po_id+');"  ><span class="l-btn-text red">关联模板展示</span></a>';
							str+= '<a href="javascript:jumpReviewModelTest('+row.f_po_id+');"  ><span class="l-btn-text red">预审模板展示</span></a>';
							return str;
						}	
					}
				]],
				singleSelect:true,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				onExpandRow: function(index,row){
					
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function(data) {
					if(data.total==0){
						alert("暂无客户绑定，请绑定客户后查看")
					}
					console.log(data.total)
					
				}
			});
		}
		function jumpModelTest(orgid){
			$.ajax({
				url:"../../content/content_list.do",
				dataType : 'json',
				data : {page : 1,
					f_cc_type:100,
					f_cc_status:1,
					f_cc_actors:"",
					rows:10,
					f_cc_companyid:orgid},
				type : 'post',
				success:function(data) {
					if(data&&data.rows.length>0){
						var serverId="";
						for(var i=0;i<data.rows.length;i++){
							if(data.rows[i].f_cc_isfree==0){
								serverId=data.rows[i].f_cc_name;
							}
						}
						if(serverId==""){
							alert("该模板无可用账号");
							return;
						}
						var url=cloudTwoPlaneUrl+"index/index_industry.jsp";
						var epg_info="<server_ip>1.1.1.1</server_ip><group_name>test</group_name><group_path></group_path><oss_user_id>0571001067</oss_user_id><page_url>http://1.1.1.1/8080/test/error.jsp</page_url><partner>xx</partner>";
						var refix =epg_info.substring(0,epg_info.indexOf("<oss_user_id>")+13);
						var suffix = epg_info.substring(epg_info.indexOf("</oss_user_id>"));
						if(data&&data.rows[0]){
							url=url+"?epg_info="+encodeURIComponent(refix+serverId+suffix);
						}else{
							url=url+"?jumpTypeId=<%=f_cc_id%>&epg_info="+encodeURIComponent(epg_info);
						}
						var win=window.open(url, "newwindow", "height=500, width=870, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
					}else{
						alert("该模板无可用账号");
					}
				}
			});
		}
		function jumpReviewModelTest(orgid){
			$.ajax({
				url:"../../content/content_list.do",
				dataType : 'json',
				data : {page : 1,
					f_cc_type:100,
					f_cc_status:1,
					f_cc_actors:"review",
					rows:10,
					f_cc_companyid:orgid},
				type : 'post',
				success:function(data) {
					if(data&&data.rows.length>0){
						var url=cloudTwoPlaneUrl+"index/index_industry.jsp";
						var epg_info="<server_ip>1.1.1.1</server_ip><group_name>test</group_name><group_path></group_path><oss_user_id>0571001067</oss_user_id><page_url>http://1.1.1.1/8080/test/error.jsp</page_url><partner>xx</partner>";
						var refix =epg_info.substring(0,epg_info.indexOf("<oss_user_id>")+13);
						var suffix = epg_info.substring(epg_info.indexOf("</oss_user_id>"));
						var value = data&&data.rows[0];
						if(value=="" || value == undefined){
							url=url+"?jumpTypeId=<%=f_cc_id%>&epg_info="+encodeURIComponent(epg_info);
						}else{
							url=url+"?epg_info="+encodeURIComponent(refix+data.rows[0].f_cc_name+suffix);
						}
						var win=window.open(url, "newwindow", "height=500, width=870, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");	
					}else{
						alert("无审核账号");
					}
					
				}
			});
		}
		function getGueryParams(){
			return {
				f_po_model:"<%=f_cc_id%>",
				f_po_name:$("#f_po_name").val(),
				sorg_startDate:$("#sorg_startDate").val(),
				sorg_endDate:$("#sorg_endDate").val()
			};
		}
		$(function(){
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			
		});
		function updatemodel(){
			var rowInfo = $("#easyui-datagrid").datagrid('getSelected');
			if(rowInfo==null){
				$.messager.alert('提示', "您未选择模板", 'info', function() {
					$.messager.progress('close');
				});
				return;	
			}
			window.parent.document.getElementById("f_po_model_name").value=rowInfo.f_cc_name;
			 window.parent.document.getElementById("f_po_model").value=rowInfo.f_cc_id;
	         //window.parent.document.getElementById("model_list").style.display="none";
	         parent.$('#model_list').dialog('close')
		}
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
	   		  	if (event.keyCode == 13){  
	      			gotoSearch($('#easyui-treegrid'));
	    		}
		}
</script>
</head>
<body>
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="模板列表"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td align="left" width="15%">模板名称：</td>
						<td align="left" width="15%"><input name="f_po_name" id="f_po_name" style="width: 150px;"  onkeydown="onpress();"/></td>
						<td align="left" width="15%">添加时间：</td>
						<td align="left" width="15%"><input name="sorg_startDate" id="sorg_startDate" onClick="WdatePicker({skin:'default',dateFmt: 'yyyy-MM-dd HH:mm:ss'})" style="width: 150px;" /></td>
						<td>—</td>
						<td><input name="sorg_endDate" id="sorg_endDate"onClick="WdatePicker({skin:'default',dateFmt: 'yyyy-MM-dd HH:mm:ss'})" style="width: 150px;"  /></td>
						
						<td align="left" width="15%">
							<limits:uiAuth url="content_list.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
							</limits:uiAuth>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>		
</body>
</html>